package com.etc.dao.impl;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.etc.dao.MusicStyleDao;
import com.etc.entity.MusicStyle;
import com.etc.util.DBUtil;

public class MusicStyleDaoImpl implements MusicStyleDao{

	@Override
	public List<MusicStyle> findAll() {
		
		List<MusicStyle> list = new ArrayList<MusicStyle>();
		ResultSet rs = DBUtil.query("SELECT style_id,style_name FROM music_style");
		try {
			while (rs.next()) {
				Integer styleId = rs.getInt("style_id");
				String styleName = rs.getString("style_name");
				
				MusicStyle musicStyle = new MusicStyle();
				musicStyle.setStyleId(styleId);
				musicStyle.setStyleName(styleName);
				
				list.add(musicStyle);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return list;
	}

}
